<?php

namespace App\Repository\Repositories;

use App\Repository\Repositories\Interfaces\ChangeRepository;
use App\Repository\Models\Change;

/**
 * Class ChangeRepositoryEloquent.
 *
 * @package namespace App\Repository\Repositories;
 */
class ChangeRepositoryEloquent extends BaseRepository implements ChangeRepository
{
	/**
	 * 搜索
	 * @var array
	 */
	protected $fieldSearchable = [
		'order_code',
		'user_name',
 		'shop_name'=>'like',
		'change_code',
		// 定义 status 搜索
		'status'=>'in',
		'created_at' => 'between',
		'change_money' => 'between',
 		'change_product' => 'like',
//		'orderProducts.product_name' => 'like',
	];


	/**
	 * 多字段联合模糊查询,前端查询字段名keyword
	 * @var array
	 */
	public $fieldFuzzySearch = [
		'shop_name',
		'change_product',//关联查询
	];

    /**
     * 将前端字段名替换为关联查询模式
     * @var array
     */
    public $fieldSearchReplace = [
    ];

    /**
     * 可关联查询的字段
     */
    public $withAllow = [
        'orderProducts'=>['product_img_url','order_code','product_name','product_id','shop_name','quantity','product_price','discount_money','product_money','freight']
    ];

	/**
	 * Specify Model class name
	 *
	 * @return string
	 */
	public function model()
	{
		return Change::class;
	}
}
